package com.p2p.front.service.impl;

import javax.annotation.Resource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.p2p.base.service.SequenceService;
import com.p2p.front.service.UserSequenceService;
import com.p2p.front.util.Sequence.SequenceName;

/**
 * @author ruiqi
 *
 */
@Service("userSequenceService")
public class UserSequenceServiceImpl implements UserSequenceService {

	@Resource
    private SequenceService sequenceService;
	
	@Override
	public String getNextUserId() {
		String str1 = String.format("%09d", getUserSequenceNext());
		String userId = "1"+str1;
		return userId;
	}

	//TODO
	public String getNextBorrowerUserId() {
		String str1 = String.format("%09d", getBorrowerUserSequenceNext());
		String userId = "2"+str1;
		return userId;
	}
	
	@Override
	public Long getUserSequenceNext() {
		return sequenceService.getNextBySequenceName(SequenceName.USER_SEQUENCE.name());
	}
	
	@Override
	public Long getBorrowerUserSequenceNext() {
		return sequenceService.getBorrowerBySequenceName(SequenceName.BORROWER_USER_SEQUENCE.name());
	}
}
